home *** CD-ROM | disk | FTP | other *** search
/ Apple Reference & Present…nuary (Partner) - Disc 1 / The Apple Reference and Presentations Library (Disc 1)(January 1994).iso / Frame Technology / US English / FrameMaker 4-68K / System Extras / PS Printer 8.1.1 / PSPrinter / PSPrinter.rsrc / PS_-8176 < prev    next >
Text File  |  1993-10-08  |  5KB  |  375 lines

  1. %%BeginFile: adobe_psp_level1_colorimage
  2. %%Copyright: Copyright 1990-1993 Adobe Systems Incorporated. All Rights Reserved.
  3. /testsystemdict
  4. {
  5. where
  6. {
  7. systemdict eq
  8. {
  9. true
  10. }{
  11. false
  12. }ifelse
  13. }{
  14. false
  15. }ifelse
  16. }bd
  17. /rgbclut Z
  18. /bwclut Z
  19. /ncolors 1 def
  20. /colorimage where{pop true}{false}ifelse
  21. {
  22. /ncolors 0
  23. statusdict begin
  24. /processcolors where
  25. {
  26. pop
  27. pop
  28. processcolors
  29. }{
  30. /deviceinfo where
  31. {pop deviceinfo/Colors known
  32. {pop{deviceinfo/Colors get}}if
  33. }if
  34. }ifelse
  35. end
  36. store
  37. ncolors 0 ne
  38. {
  39. /colorimage testsystemdict
  40. /setcolortransfer testsystemdict
  41. /currentcolortransfer testsystemdict
  42. /currentcmykcolor testsystemdict
  43. and and and not
  44. {
  45. /ncolors 0 store
  46. }if
  47. }if
  48. }if
  49. ncolors 1 ne ncolors 3 ne ncolors 4 ne and and{/ncolors 0 store}if
  50. ncolors 1 ne dup startnoload
  51. /expandfactor Z
  52. /bwclut Z
  53. /expandbw
  54. {
  55. expandfactor mul round cvi bwclut exch get 255 div
  56. }bd
  57. /:k
  58. {
  59. pop/bwclut xs
  60. bpc dup 8 eq
  61. {
  62. pop 255
  63. }{
  64. 4 eq
  65. {
  66. 15
  67. }{
  68. 3
  69. }ifelse
  70. }ifelse
  71. /expandfactor xs
  72. [
  73. /expandbw load/exec load dup
  74. currenttransfer exch
  75. ]cvx bind settransfer
  76. iw ih bpc[iw 0 0 ih 0 0]setupimageproc
  77. image
  78. }bd
  79. endnoload
  80. ncolors dup 3 eq exch 4 eq or
  81. not dup startnoload
  82. /Dclut Z
  83. /Cclut Z
  84. /Bclut Z
  85. /Aclut Z
  86. /ncompute Z
  87. /rclut Z
  88. /gclut Z
  89. /bclut Z
  90. /bit3x Z
  91. /bit1x Z
  92. /concatutil
  93. {
  94. /exec load
  95. 7 -1 roll/exec load
  96. }bd
  97. /defsubclut
  98. {
  99. 1 add getinterval store
  100. }bd
  101. /spconcattransfer
  102. {
  103. /Dclut xs
  104. /Cclut xs
  105. /Bclut xs
  106. /Aclut xs
  107. /ncompute exch load store
  108. currentcolortransfer
  109. [
  110. {
  111. Aclut ncompute
  112. }
  113. concatutil
  114. ]cvx
  115. [
  116. {
  117. Bclut ncompute
  118. }
  119. concatutil
  120. ]cvx
  121. [
  122. {
  123. Cclut ncompute
  124. }
  125. concatutil
  126. ]cvx
  127. [
  128. {
  129. Dclut ncompute
  130. }
  131. concatutil
  132. ]cvx
  133. setcolortransfer
  134. }bd
  135. /setuprgbcluts
  136. {
  137. /bit3x
  138. rgbclut length
  139. 3 sub
  140. store
  141. /bit1x bit3x 3 idiv store
  142. /rclut rgbclut store
  143. /gclut rclut 1 bit3x defsubclut
  144. /bclut rclut 2 bit3x defsubclut
  145. }bd
  146. endnoload
  147. ncolors 3 ne
  148. dup startnoload
  149. /3compute
  150. {
  151. exch bit3x
  152. mul
  153. round
  154. cvi
  155. get 255 div
  156. }bd
  157. /:k
  158. {
  159. /rgbclut xs
  160. /bwclut xs
  161. setuprgbcluts
  162. /3compute rclut gclut bclut dup
  163. spconcattransfer
  164. iw ih bpc[iw 0 0 ih 0 0]
  165. [
  166. setupimageproc/exec load
  167. /dup load dup
  168. ]cvx
  169. {}{}true 3 colorimage
  170. }bd
  171. endnoload
  172. ncolors 4 ne
  173. dup startnoload
  174. /cmykindex Z
  175. /bit4x Z
  176. /cmykclut Z
  177. /cclut Z
  178. /mclut Z
  179. /yclut Z
  180. /kclut Z
  181. /ftoint
  182. {
  183. 1 exch sub 255 mul round cvi
  184. }bd
  185. /stuffclut
  186. {
  187. cmykindex 3 -1 roll put
  188. }bd
  189. /4compute{exch bit4x mul round cvi get 255 div}bd
  190. /invalidcolortable? true def
  191. /computecmykclut
  192. {
  193. setuprgbcluts
  194. /bit4x
  195. rgbclut length
  196. 3 idiv
  197. 4 mul
  198. 4 sub
  199. store
  200. /cmykclut bit4x 4 add string store
  201. /cclut cmykclut store
  202. /mclut cclut 1 bit4x defsubclut
  203. /yclut cclut 2 bit4x defsubclut
  204. /kclut cclut 3 bit4x defsubclut
  205. /cmykindex 0 store
  206. 0 1 bit1x
  207. {
  208. dup/cmykindex exch
  209. bit1x exch sub
  210. 4 mul store
  211. 3 mul dup
  212. rclut exch get 255 div
  213. exch dup
  214. gclut exch get 255 div
  215. exch
  216. bclut exch get 255 div
  217. setrgbcolor currentcmykcolor
  218. ftoint
  219. kclut stuffclut
  220. ftoint
  221. yclut stuffclut
  222. ftoint
  223. mclut stuffclut
  224. ftoint
  225. cclut stuffclut
  226. }for
  227. }bd
  228. /:k
  229. {
  230. /rgbclut xs
  231. /bwclut xs
  232. invalidcolortable?
  233. {
  234. computecmykclut
  235. }if
  236. /4compute cclut mclut yclut kclut spconcattransfer
  237. iw ih bpc[iw 0 0 ih 0 0]
  238. [
  239. setupimageproc/exec load
  240. /dup load dup dup
  241. ]cvx
  242. {}{}{}
  243. true 4 colorimage
  244. }bd
  245. endnoload
  246. ncolors 0 ne
  247. dup startnoload
  248. /byte Z
  249. /$x Z
  250. /padfix Z
  251. /lookupandstore
  252. {
  253. 3 mul
  254. 3 getinterval
  255. putinterval exch
  256. 3 add exch 3 copy
  257. }bd
  258. /8lookup/lookupandstore load store
  259. /4lookup
  260. {
  261. /byte 1 index store
  262. -4 bitshift
  263. lookupandstore
  264. byte 15 and
  265. lookupandstore
  266. }bd
  267. /2lookup
  268. {
  269. /byte 1 index store
  270. -6 bitshift
  271. lookupandstore
  272. byte -4 bitshift
  273. 3 and
  274. lookupandstore
  275. byte -2 bitshift
  276. 3 and
  277. lookupandstore
  278. byte 3 and
  279. lookupandstore
  280. }bd
  281. /colorexpand
  282. {
  283. $x 0 rgbclut
  284. 3 copy
  285. 7 -1 roll
  286. /$l load
  287. forall
  288. pop pop pop pop pop
  289. 0 padfix getinterval
  290. }bd
  291. /createexpandstr
  292. {
  293. /$x exch $z length mul string store
  294. }bd
  295. /:k
  296. {
  297. /rgbclut xs
  298. /bwclut xs
  299. /$l
  300. bpc 8 eq
  301. {
  302. 3 createexpandstr
  303. /8lookup
  304. }{
  305. bpc 4 eq
  306. {
  307. 6 createexpandstr
  308. /4lookup
  309. }{
  310. 12 createexpandstr
  311. /2lookup
  312. }ifelse
  313. }ifelse
  314. load store
  315. /padfix 3 iw mul store
  316. iw ih 8[iw 0 0 ih 0 0]
  317. [setupimageproc/exec load/colorexpand load/exec load]cvx
  318. false 3 colorimage
  319. }bd
  320. endnoload
  321. /colorimage where
  322. {
  323. systemdict eq
  324. {
  325. systemdict/setcmykcolor known
  326. }{
  327. true
  328. }ifelse
  329. }{
  330. false
  331. }ifelse
  332. dup not startnoload
  333. /:l
  334. {
  335. iw ih 8[iw 0 0 ih 0 0]
  336. setupimageproc false 3
  337. colorimage
  338. }bd
  339. dup not endnoload
  340. dup startnoload
  341. /str Z
  342. /len Z
  343. /smlen Z
  344. /rstr Z
  345. /gstr Z
  346. /bstr Z
  347. /rgbtogray
  348. {
  349. /str xs
  350. /len str length store
  351. /smlen len 3 idiv store
  352. /rstr str store
  353. /gstr str 1 len 1 sub getinterval store
  354. /bstr str 2 len 2 sub getinterval store
  355. str dup
  356. 0 1 smlen 1 sub
  357. {
  358. dup 3 mul
  359. rstr 1 index get .3 mul
  360. gstr 2 index get .59 mul add
  361. bstr 3 -1 roll get .11 mul add
  362. round cvi
  363. put dup
  364. }for
  365. pop 0 smlen getinterval
  366. }bd
  367. /:l
  368. {
  369. iw ih 8[iw 0 0 ih 0 0]
  370. [setupimageproc/exec load/rgbtogray load/exec load]cvx bind
  371. image
  372. }bd
  373. endnoload
  374. %%EndFile
  375.